/** `94` 二叉树的中序遍历
 
 */


use std::rc::Rc;
use std::cell::RefCell;
use crate::solution::Solution;
use crate::tree_node::TreeNode;


impl Solution {
  
  fn dfs(root :&Option<Rc<RefCell<TreeNode>>> ,ans: &mut Vec<i32>){
    if root.is_none() {
      return;;
    }
    let node = root.as_ref().unwrap().borrow();
    Self::dfs(&node.left,ans);
    ans.push(node.val);
    Self::dfs(&node.right,ans);
  }
    pub fn inorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
      let mut ans = vec![];
      Self::dfs(&root,&mut  ans);
      ans
    }
}